package com.android.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.R;
import com.android.activity.DeliverActivity;
import com.android.model.Delivery;

import java.util.List;

public class DeliverysAdapter extends ArrayAdapter<Delivery> {


    private List<Delivery> mNewsData;
    private Context mContext;
    private int resourceId;

    public DeliverysAdapter(Context context, int resourceId, List<Delivery> data) {
        super(context, resourceId, data);
        this.mContext = context;
        this.mNewsData = data;
        this.resourceId = resourceId;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Delivery deliverys = getItem(position);
        View view ;

        view = LayoutInflater.from(getContext()).inflate(resourceId, parent, false);

        TextView tvreceiver  = view.findViewById(R.id.tv_delivery_receiver);
        TextView tvphone = view.findViewById(R.id.tv_delivery_phone);
        TextView tvloc = view.findViewById(R.id.tv_delivery_location);

        tvreceiver.setText(deliverys.getReceiver());
        tvphone.setText(deliverys.getPhone());
        tvloc.setText(deliverys.getLocation());
        return view;
    }
}
